<%@ page language="java" contentType="text/javascript; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import='java.sql.*' %>
<%@page import="java.util.ArrayList"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.json.JSONSerializer"%>
<%@page import="net.sf.json.JSONArray"%>
<%@page import="javapns.back.PushNotificationManager"%>
<%@page import="javapns.back.SSLConnectionHelper"%>
<%@page import="javapns.data.Device"%>
<%@page import="javapns.data.PayLoad"%>
<%@page import="java.lang.Object"%>
<%@page import="org.apache.commons.lang.StringUtils"%>

<%String callback = request.getParameter("callback");%>
<%=callback %> (<%

	String deviceToken = request.getParameter("regid");
	
	PayLoad payLoad = new PayLoad();
	payLoad.addAlert("Hello");
	payLoad.addBadge(1);
	payLoad.addSound("default");
	
	PushNotificationManager pushManager = PushNotificationManager.getInstance();
	pushManager.addDevice("iPhone", deviceToken);
	
	String host = "gateway.sandbox.push.apple.com";
	int port = 2195;
	String certificatePath = "Triends.p12";
	String certificatePassword = "SUDadventurer2";
	pushManager.initializeConnection(host, port, certificatePath, certificatePassword, 
			SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);
	
	Device client = pushManager.getDevice("iPhone");
	pushManager.sendNotification(client, payLoad);
	pushManager.stopConnection();
	pushManager.removeDevice("iPhone");
	
%>);